﻿using System;
using System.Data;

namespace Titan.FIS.SampleRecd.DataOperate
{
	public class DataExecProc
	{
		/// <summary>
		/// 查询并更新样桶信息
		/// </summary>      
		/// <param name="strRfid"></param>
		/// <param name="strType"></param>
		/// <param name="strBatchCode"></param>
		/// <param name="strMaterielName">0收样号，1批次号</param>
		/// <param name="strSuplierName"></param>
		/// <param name="strTransportName"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoExecPailInfo(string strRfid, string strType, ref string strBatchCode, ref string strMaterielName, ref string strSuplierName, ref string strTransportName, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{  new Titan.DAS.Msg.Common.ProcParam{Name = "P_RFID",Value = strRfid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_TYPE",Value = strType,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_BATCH_CODE",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_MATERIEL_NAME",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_SUPPLIER_NAME",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_TRANSPORT_NAME",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_SAMPLE_MANAGER.PROC_RECEIVE_SAMPLE", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				strTransportName = modelProc.RParams[modelProc.RParams.Length - 3].Value.ToString();
				strSuplierName = modelProc.RParams[modelProc.RParams.Length - 4].Value.ToString();
				strMaterielName = modelProc.RParams[modelProc.RParams.Length - 5].Value.ToString();
				strBatchCode = modelProc.RParams[modelProc.RParams.Length - 6].Value.ToString();
				bResult = true;
			}
			return bResult;
		}
		/// <summary>
		/// 读卡分样
		/// </summary>
		/// <param name="strRfidCode"></param>
		/// <param name="strPCode"></param>
		/// <param name="strSampleNo"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoSubSample(string strRfidCode, ref string strPCode, ref string strSampleNo, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{  new Titan.DAS.Msg.Common.ProcParam{Name = "STRRFID",Value = strRfidCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRSUNAME",Value = Common.UserInfo.UserName,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRRUNAME",Value = Common.UserInfo.UserName,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRNO",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRPCODE",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_PDAMANAGE.SAMPLESORT_NO", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				strSampleNo = modelProc.RParams[modelProc.RParams.Length - 4].Value.ToString();
				strPCode = modelProc.RParams[modelProc.RParams.Length - 3].Value.ToString();
				bResult = true;
			}
			return bResult;
		}
		/// <summary>
		/// 条形码分样
		/// </summary>
		/// <param name="strRfidCode"></param>
		/// <param name="strPCode"></param>
		/// <param name="strSampleNo"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoSubSampleNew(string strRfidCode, string strPCode, ref string strSampleNo, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{  new Titan.DAS.Msg.Common.ProcParam{Name = "STRRFID",Value = strRfidCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRPCODE",Value = strPCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRWEIGHT",Value = 0,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRSUNAME",Value = Common.UserInfo.UserName,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRRUNAME",Value = Common.UserInfo.UserName,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRNO",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_PDAMANAGE.SAMPLESORT_NEW", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				strSampleNo = modelProc.RParams[modelProc.RParams.Length - 3].Value.ToString();
				bResult = true;
			}
			return bResult;
		}
		
		/// <summary>
		/// 合样制样提交
		/// </summary>
		/// <param name="strPCode"></param>
		/// <param name="strRfids"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoBlendPost(string strPCode, string strRfids, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{  new Titan.DAS.Msg.Common.ProcParam{Name = "STRPCODE",Value = strPCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRHYTYPE",Value = 0,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRSSTYPE",Value = 0,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRUSER",Value = Common.UserInfo.UserName,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRYPCODES",Value = strRfids,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "STRWEIGHT",Value = 0,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_PDAMANAGE.BLENDPOST", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				bResult = true;
			}
			return bResult;
		}

		/// <summary>
		/// 添加样品校验
		/// </summary>
		/// <param name="strCode"></param>
		/// <param name="strType"></param>
		/// <param name="strMode">0收样编码，1批次编码，2人工采样号，3自动制样，4抽查样</param>
		/// <param name="strSampleCode"></param>
		/// <param name="strRfid"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoCheckSample(string strCode, string strType, string strMode, ref string strSampleNum, ref string strLmsReceive, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{  new Titan.DAS.Msg.Common.ProcParam{Name = "P_CODE",Value = strCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_TYPE",Value = strType,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_STYPE",Value = strMode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLE_NUM",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_LMS_RECEIVE",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_SAMPLE_MANAGER.PROC_CHECK_SCODE", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				strLmsReceive = modelProc.RParams[modelProc.RParams.Length - 3].Value.ToString();
				strSampleNum = modelProc.RParams[modelProc.RParams.Length - 4].Value.ToString();
				bResult = true;
			}
			return bResult;
		}

		/// <summary>
		/// 添加样品
		/// </summary>
		/// <param name="strCode"></param>
		/// <param name="strRfid"></param>
		/// <param name="strType"></param>
		/// <param name="strMode">0收样编码，1批次编码，2人工采样号，3自动制样，4抽查样</param>
		/// <param name="strSampleCode"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoAddSample(string strCode, string strRfid, string strType, string strMode, ref string strSampleCode, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{  new Titan.DAS.Msg.Common.ProcParam{Name = "P_CODE",Value = strCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_RFID",Value = strRfid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_TYPE",Value = strType,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_STYPE",Value = strMode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_USER",Value = Common.UserInfo.UserId,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLE_CODE",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_SAMPLE_MANAGER.PROC_INSERT_SCODE", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				strSampleCode = modelProc.RParams[modelProc.RParams.Length - 3].Value.ToString();
				bResult = true;
			}
			return bResult;
		}

		/// <summary>
		/// 添加样品
		/// </summary>
		/// <param name="strCode"></param>
		/// <param name="strType"></param>
		/// <param name="strMode">0收样编码，1批次编码，2人工采样号，3自动制样，4抽查样</param>
		/// <param name="strHCode"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoAddSampleMt(string strCode,  string strType, string strMode, ref string strHCode, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{  new Titan.DAS.Msg.Common.ProcParam{Name = "P_CODE",Value = strCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_TYPE",Value = strType,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_STYPE",Value = strMode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_USER",Value = Common.UserInfo.UserId,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_H_CODE",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_SAMPLE_MANAGER.PROC_INSERT_SCODE_MT", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				strHCode = modelProc.RParams[modelProc.RParams.Length - 3].Value.ToString();
				bResult = true;
			}
			return bResult;
		}

		/// <summary>
		/// 添加样品
		/// </summary>
		/// <param name="strCode"></param>
		/// <param name="strRfid"></param>
		/// <param name="strType"></param>
		/// <param name="strMode">0收样编码，1批次编码，2人工采样号，3自动制样，4抽查样</param>
		/// <param name="strBatchCode"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>strDate, strType, strCoal, strSupplier, strRfid,
		public static bool DoAddSelfSample(string strDate, string strType, string strCoal, string strSupplier, string strTeam, string strRfid, ref string strBatchCode, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{  new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLEDATE",Value = strDate,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_TYPE",Value = strType,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_COAL",Value = strCoal,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_SUPPLIER",Value = strSupplier,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_TEAM",Value = strTeam,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_RFID",Value = strRfid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_USER",Value = Common.UserInfo.UserId,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_BATCH_CODE",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_SAMPLE_MANAGER.PROC_INSERT_SELFSAMPLE", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				strBatchCode = modelProc.RParams[modelProc.RParams.Length - 3].Value.ToString();
				bResult = true;
			}
			return bResult;
		}

		/// <summary>
		/// 删除打印次数为0的样品
		/// </summary>
		/// <param name="strSampleCode"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoDeleteSample(string strSampleCode, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLE_CODE",Value = strSampleCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_SAMPLE_MANAGER.PROC_DELETE_SCODE", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				bResult = true;
			}
			return bResult;
		}

		/// <summary>
		/// 更新样品重量
		/// </summary>
		/// <param name="strSampleCode"></param>
		/// <param name="strWeight"></param>
		/// <param name="strWeightState"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoUpdateSampleWeight(string strSampleCode, string strWeight, string strWeightState, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLE_CODE",Value = strSampleCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_WEIGHT",Value = strWeight,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_WEIGHTSTATE",Value = strWeightState,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_USER",Value = Common.UserInfo.UserId,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_SAMPLE_MANAGER.PROC_UPDATE_SAMPLEWEIGHT", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				bResult = true;
			}
			return bResult;
		}
		
		/// <summary>
		/// 更新样品条码打印次数
		/// </summary>
		/// <param name="strSampleCode"></param>
		/// <param name="strPrintType">打印类型0：试样编码，1：化验编码，2：批次编码，3：根据试样编码更新化验编码</param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoUpdatePrintCount(string strSampleCode, string strPrintType, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLE_CODE",Value = strSampleCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_PRINT_TYPE",Value = strPrintType,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_SAMPLE_MANAGER.PROC_UPDATE_PRINTCOUNT", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				bResult = true;
			}
			return bResult;
		}

		/// <summary>
		/// 化验收样样品校验
		/// </summary>
		/// <param name="strCode"></param>
		/// <param name="strSampleType"></param>
		/// <param name="strSampleNum"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoCheckReceiveBatch(string strCode, ref string strSampleType, ref string strSampleNum, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{  new Titan.DAS.Msg.Common.ProcParam{Name = "P_CODE",Value = strCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLE_TYPE",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLE_NUM",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_SAMPLE_MANAGER.PROC_CHECK_REVBATCHCODE", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				strSampleNum = modelProc.RParams[modelProc.RParams.Length - 3].Value.ToString();
				strSampleType = modelProc.RParams[modelProc.RParams.Length - 4].Value.ToString();
				bResult = true;
			}
			return bResult;
		}

		/// <summary>
		/// 化验收样
		/// </summary>
		/// <param name="strSCode"></param>
		/// <param name="strSendUserID"></param>
		/// <param name="strTestCode"></param>
		/// <param name="strErrInfo"></param>
		/// <returns></returns>
		public static bool DoAddReceiveSample(string strSCode, string strSendUserID, ref string strTestCode, ref string strErrInfo)
		{
			var bResult = false;
			var parms = new DAS.Msg.Common.ProcParam[]{  new Titan.DAS.Msg.Common.ProcParam{Name = "P_SCODE",Value = strSCode,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_SUSER",Value = strSendUserID,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_USER",Value = Common.UserInfo.UserId,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_TEST_CODE",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=20},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = 0,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
											   new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRMSG",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};

			var modelProc = Titan.DAS.Client.Data.DataHelper.Instance.ExecProc(Common.UserInfo.UserName, Common.UserInfo.UserPwd, "PCK_SAMPLE_MANAGER.PROC_INSERT_HCODE", parms);
			if (!modelProc.RSuccess || modelProc.RStatuCode != 1)
				strErrInfo = string.Format("操作失败!\r\n错误代码:{0}  错误描述:{1}", modelProc.RStatuCode, modelProc.RStatuDesc);
			else
			{
				strErrInfo = modelProc.RParams[modelProc.RParams.Length - 1].Value == null ? string.Empty : modelProc.RParams[modelProc.RParams.Length - 1].Value.ToString().Replace("null", "").Trim();
				if (!string.IsNullOrEmpty(strErrInfo)) return false;
				strTestCode = modelProc.RParams[modelProc.RParams.Length - 3].Value.ToString();
				bResult = true;
			}
			return bResult;
		}
		
	}
}
